/*
 * @Description: 
 * @Author: Aroma
 * @Date: 2024-09-03 11:38:08
 * @LastEditors: Aroma
 * @LastEditTime: 2024-09-03 15:19:37
 * @别瞎看: 你个无脑牛马
 */
import java.util.Scanner;
import java.util.Random;
public class Test_GuessNumber{
    public static void main(String[] args) {
        //创建一个random对象用于生成随机数
        Random random=new Random();
        // //用random对象生成一个1-100之间的随机数
        int randomNumber=random.nextInt(100)+1;
        // //输出随机数
        System.out.println("RandomNumber"+randomNumber);
        //获取用户输入
        Scanner scanner=new Scanner(System.in);
        //不确定次数 用while
        while (true){
            //提示用户输入1-100数值
            System.out.println("请输入1-100数值：");
            // int num=scanner.nextInt();
            
            if (!scanner.hasNextInt()){
                if(scanner.nextLine().equals("exit")){
                    System.out.println("已成功退出游戏");
                    break;
                }else {
                    System.out.println("输入错误，请输入数值");
                    continue;
                }
            }
            int cs= scanner.nextInt();
        
            if(cs> randomNumber){
                System.out.println("猜大了");
                // ++i;
                continue;
            }else{
                if (cs< randomNumber){
                    System.out.println("猜小了");
                    // ++i;
                    continue;
                }else {
                    System.out.printf("恭喜你猜对了");
                    break;
                }
            }
        }
    }

    private static Object random(Random random2) {
        // TODO Auto-generated method stub
        throw new UnsupportedOperationException("Unimplemented method 'random'");
    }
}